
package uk.ac.cam.cl.oscar.sift;

import java.awt.image.BufferedImage;
import java.io.*;

/**
 * A Keypoint is a significant point location on an image
 * that represents a change of gradient in the colour.
 */
public class Keypoint implements Serializable
{
    // The DoG image used to generate the keypoint
    transient BufferedImage image;
    // The (x,y) location of the keypoint, the scale of the
    // DoG image, the relative scale of the keypoint and the
    // orientation [-PI,PI]
    double x, y, imgScale, scale, orientation;
    // The descriptors associated with this keypoint
    KeypointDescriptor kpd;

    // Lots of functions that return the private variables
    public BufferedImage getImage() { return this.image; }
    public double getX() { return this.x; }
    public double getY() { return this.y; }
    public double getImgScale() { return this.imgScale; }
    public double getScale() { return this.scale; }
    public double getOrientation() { return this.orientation; }

    // Lots of functions that change the private variables
    public void setX(double newx) { this.x = newx; }
    public void setY(double newy) { this.y = newy; }
    public void setImgScale(double newiscale) { this.imgScale = newiscale; }
    public void setScale(double newscale) { this.scale = newscale; }
    public void setOrientation(double newori) { this.orientation = newori; }

    // Funcs to set and get the keypoint descriptor for this keypoint
    public void addDescriptor(KeypointDescriptor nkpd) { this.kpd = nkpd; }
    public KeypointDescriptor getDescriptor() { return this.kpd; }

    // Sets up the Keypoint with all the given variables
    public Keypoint(BufferedImage image, double x, double y, double imgScale, double kpScale, double orientation)
    {
        this.image = image;
        this.x = x;
        this.y = y;
        this.imgScale = imgScale;
        this.scale = kpScale;
        this.orientation = orientation;
        this.kpd = null;
    }
}
